package org.example.bombermanserver.model;

import com.fasterxml.jackson.annotation.JsonInclude;

/**
 * 游戏消息类
 * type: MOVE, BOMB, EXPLODE, ITEM, DEAD, ROOM_UPDATE, CHAT
 * 可选字段根据事件类型使用
 */
@JsonInclude(JsonInclude.Include.NON_NULL) // 序列化时忽略空字段
public class Message {

    private String type;
    private String playerId;
    private Integer x;
    private Integer y;
    private String direction;

    private String bombId;
    private String itemType;
    private Object roomState;
    private String content;

    public Message() {}

    // 仅带 type 的构造器
    public Message(String type) {
        this.type = type;
    }

    // 全参构造器
    public Message(String type, String playerId, Integer x, Integer y, String direction,
                   String bombId, String itemType, Object roomState, String content) {
        this.type = type;
        this.playerId = playerId;
        this.x = x;
        this.y = y;
        this.direction = direction;
        this.bombId = bombId;
        this.itemType = itemType;
        this.roomState = roomState;
        this.content = content;
    }

    // getter & setter
    public String getType() { return type; }
    public void setType(String type) { this.type = type; }

    public String getPlayerId() { return playerId; }
    public void setPlayerId(String playerId) { this.playerId = playerId; }

    public Integer getX() { return x; }
    public void setX(Integer x) { this.x = x; }

    public Integer getY() { return y; }
    public void setY(Integer y) { this.y = y; }

    public String getDirection() { return direction; }
    public void setDirection(String direction) { this.direction = direction; }

    public String getBombId() { return bombId; }
    public void setBombId(String bombId) { this.bombId = bombId; }

    public String getItemType() { return itemType; }
    public void setItemType(String itemType) { this.itemType = itemType; }

    public Object getRoomState() { return roomState; }
    public void setRoomState(Object roomState) { this.roomState = roomState; }

    public String getContent() { return content; }
    public void setContent(String content) { this.content = content; }

    @Override
    public String toString() {
        return "Message{" +
                "type='" + type + '\'' +
                ", playerId='" + playerId + '\'' +
                ", x=" + x +
                ", y=" + y +
                ", direction='" + direction + '\'' +
                ", bombId='" + bombId + '\'' +
                ", itemType='" + itemType + '\'' +
                ", roomState=" + roomState +
                ", content='" + content + '\'' +
                '}';
    }
}
